<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>首页</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" href="../lib/mui-master/dist/css/mui.min.css">
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <!-- <link rel="stylesheet" type="text/css" href="../css/aui-flex.css" /> -->
    <link rel="stylesheet" type="text/css" href="../css/aui-slide.css" />
    <link rel="stylesheet" type="text/css" href="../css/index.css" />
    <link rel="stylesheet" type="text/css" href="../icon/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../icon/font-awesome/css/font-awesome.css" />
    <style>
        .aui-grid [class*=aui-col-],
        .aui-grid-label {
            padding: .2rem 0 !important;
        }

        .aui-grid .aui-grid-label {
            margin: 0;
        }

        input[type=search] {
            background: #FFF;
        }

        body {
            background-color: #FFF;
        }

        #search {
            position: relative;
            padding: 0.3rem 0.8rem;
            line-height: 2.2rem;
            display: flex;
            justify-content: space-around;
        }

        #search span {
            font-size: 0.8rem;
            color: #fff;
            line-height: 1.6rem
        }

        #search i {
            position: absolute;
            top: 0.1rem;
            left: 13.5rem;
            font-size: 1rem
        }

        #search_input {
            width: 14rem;
            height: 1.6rem;
            border-radius: 1.6rem;
            text-align: left;
            padding-left: 1rem
        }

        .max2line {
            margin-bottom: 0
        }

        .aui-card-list-content-padded {
            padding: 0;
        }

        .aui-card-list-content-padded video {
            width: 100%;
            height: 10rem
        }

        .footer_right .comment,
        .footer_right .like {
            font-size: 0.75rem
        }

        .zan_icon.active {
            color: rgb(201, 22, 26);
        }

        .video {
            width: 100%;
            height: 10rem;
            background-color: #000;
            border: none;
        }

        .more {
            width: 1.5rem;
            height: 1.5rem;
            position: absolute;
            right: .5rem;
            top: .5rem;
            z-index: 999;
            /*background-color: rgba(0, 0, 0, 0.5);
            color: rgba(255, 255, 255, 0.7);
            width: 2.8rem;
            height: 1.3rem;
            line-height: 1.3rem;
            text-align: center;
            font-size: 0.8rem;*/
        }

        .lunbo-img {
            width: 100%;
            height: 100%;
        }

        .tabList {
            padding: 0 0.5rem;
            width: 100%;
            height: 2.5rem;
            overflow-x: auto!important;
            white-space: wrap;
            border: 4px solid #EEE;
            border-right: 0;
            border-left: 0;
        }

        .tabList::-webkit-scrollbar {
            display: none
        }

        .tab_item {
            float: left;
            width: 12.5%;
            text-align: center;
            line-height: 1.5rem;
            height: 1.5rem;
        }

        .tab_item.active {
            color: #fff;
            background-color: rgb(211, 155, 81);
        }
    </style>
</head>

<body style="-webkit-user-select:all">
    <!-- <header class="aui-bar aui-bar-nav" id="aui-header" style="background-color:#D39B51;position:fixed;width:100%">
        <div class="aui-searchbar" id="search" style="margin-top:1.2rem">
            <input type="search" placeholder="请输入您想要搜索内容" id="search_input">
            <i class="iconfont icon-seachx" id="searchText"></i>
            <span id="quxiao">取消</span>
        </div>
    </header> -->
    <!-- main content -->
    <div class="mainContent" style="width:100%;overflow:hidden">
        <!-- 轮播图 -->
        <div id="slider" class="mui-slider" style="position:relative;width:100%;">
            <div class="mui-slider-group mui-slider-loop" id="mui_banner" style="height:10rem;">

            </div>
            <div class="mui-slider-indicator">

            </div>
            <div class="more"><i style="color:#D39B51;font-size:1.2rem;" class="fa fa-chevron-circle-right"></i></div>
        </div>
        <section class="aui-content aui-margin-b-15 menulist" style="margin-bottom:.1rem !important">
            <div class="aui-grid aui-padded-l-10 aui-padded-r-10">
                <div class="aui-row aui-row-padded" style="display: flex;justify-content: space-between;">
                    <div class="aui-col-5" onclick="btn_travel()">
                        <img style="width:4.5rem;" src="../image/demo/i1.png" class="icon">
                        <div class="aui-grid-label">文化旅游</div>
                    </div>
                    <div class="aui-col-5" onclick="btn_cate()">
                        <img style="width:4.5rem;" src="../image/demo/i3.png" class="icon">
                        <div class="aui-grid-label">美食特产</div>
                    </div>
                    <div id="codePay" class="aui-col-5" onclick="codePay('camera');">
                        <img style="width:4.5rem;" src="../image/demo/i2.png" class="icon">
                        <div class="aui-grid-label">扫码支付</div>
                    </div>
                    <div class="aui-col-5" onclick="btn_giftBag()">
                        <img style="width:4.5rem;" src="../image/demo/i4.png" class="icon">
                        <div class="aui-grid-label">领取礼包</div>
                    </div>
                    <div class="aui-col-5" onclick="btn_generalize()">
                        <img style="width:4.5rem;" src="../image/demo/i5.png" class="icon">
                        <div class="aui-grid-label">邀请好友</div>
                    </div>
                </div>
            </div>
        </section>
        <div class="tabList" style="margin:.25rem 0;">
            <div style="width:200%;margin:.3rem 0;" id="tabBox">
                <!-- <div class="tab_item active">Item1</div>
            <div class="tab_item">Item2</div>
            <div class="tab_item">Item3</div>
            <div class="tab_item">Item4</div>
            <div class="tab_item">Item5</div> -->
            </div>
        </div>

        <!-- 分类内容展示 -->
        <div class="wapper-box" id="newsListAll" style="background-color:#eee">

        </div>
        <div id="down" style="height:1rem;text-align:center;display:none;font-size:0.7rem;color:#ccc">
            ---人家也是有底线的!---
        </div>
        <!-- 协议提示 -->
        <div id="id_shadowBox" class="shadowBox" style="position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color: rgba(0,0,0,0);z-index: 99;display: none;align-items: center;">
    		<div id="id_box" class="box" style="width: 12rem;height: 14rem;background-color: #fff;margin: 0 auto;border-radius: 5px;padding: 0.8rem;position: relative;text-align: center;box-shadow: 0 0 10px #ccc">
    			<div class="title" style="font-size: 0.8rem;margin-bottom: 0.4rem;color: #000">用户协议和隐私协议</div>
    			<div class="content" style="font-size: 0.6rem;text-align: left;">请你务必阅读、充分理解 "用户协议" 和 "隐私协议" 各条款、包括但不限于：为了向你提供即时通讯、内容分享等服务,我们需要收集你的设备信息、操作日志等个人信息。你可以在"设置"中查看、变更、删除个人信息并管理你的授权。<br/>
    				你可阅读<span style="color: #d49b54" onclick="btn_win()">《用户协议》</span>&&<span style="color: #d49b54" onclick="btn_win()">《隐私协议》</span>了解详细信息。如你同意,请点击"同意"开始接受我们的服务。
    			</div>
    			<div class="btnBox" style="position: absolute;bottom: 0;left: 0;height: 1.9rem;width: 100%;display: flex;justify-content: space-between;border-top: 1px solid #eee;font-size: 0.9rem;">
    				<div class="left" style="height: 100%;width: 50%;line-height: 1.9rem;" onclick="btnLeft()">暂不使用</div>
    				<div class="right" style="height: 100%;width: 50%; line-height: 1.9rem;color: #d49b54" onclick="btnRight()">同意</div>
    			</div>
    		</div>
    		<!--限制框-->
    		<div id="id_box2" class="box2" style="width: 12rem;height: 7rem;background-color: #fff;margin: 0 auto;border-radius: 5px;padding: 0.8rem;position: relative;text-align: center;display: none;box-shadow: 0 0 10px #ccc">
    			<div class="title" style="font-size: 0.8rem;margin-bottom: 0.4rem;color: #000">提示</div>
    			<div class="content" style="font-size: 0.6rem;text-align: center;">您取消了授权,需授权后才能向您提供服务!</div>
    			<div class="btnBox" style="position: absolute;bottom: 0;left: 0;height: 1.9rem;width: 100%;border-top: 1px solid #eee;font-size: 0.9rem;" onclick="btnYes()">确定</div>
    		</div>
    	</div>
    </div>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/dns.js"></script>
<script type="text/javascript" src="../lib/artTemplate/template.js"></script>
<script type="text/javascript" src="../script/aui-tab.js"></script>
<script type="text/javascript" src='../lib/mui-master/dist/js/mui.min.js'></script>
<script type="text/javascript" src="../script/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../script/aui-toast.js"></script>
<script type="text/html" id="tabList">
    {{each items as value index}}
    <div class="tab_item">{{value}}</div>
    {{/each}}
</script>
<!-- 全部新闻模板 -->
<script type="text/html" id="newsAll">
    {{each items as value index}}
    <!-- 判断是否置顶 -->
    {{if items[index].top==2}}
    <div class="istop" style="padding:0.2rem .5rem;background-color:#fff;">
        <div class="max2line btn_activeId" articleID="{{value.id}}" style="display: inline" onclick="btn_active1(this)">{{value.title}}</div>
        <div class="topbox" style="border-bottom:1px solid #EEE;padding:0 0 .5rem 0;">
            <div class="aui-btn" style="line-height:1.2rem;height:1.2rem;font-size:.7rem;background:rgb(211, 155, 81);color:#FFF;margin:.3rem 0 0 0;">置顶</div>
            <div style="float:right; color:#A8A8A8;" class="footer_right" articleID="{{value.id}}">
                <span articleID="{{value.id}}" class="ping btn_activeId" onclick="getcomment(this)"><span articleID="{{value.id}}" class="iconfont icon-pinglunzhuanhuan btn_activeId" style="font-size:0.95rem;"></span>&nbsp;<span class="comment comment{{value.id}}">{{value.comment_num}}</span>                &nbsp;</span>
                {{if value.tid.is_awesome=="yes"}}
                <span class="zan" onclick="getdianzan(this)"><span class="iconfont icon-dianzan zan_icon active" style="font-size:0.7rem;"></span>&nbsp;<span class="like like{{value.id}}">{{value.awesome_num+value.virtual_awesome_num}}</span></span>
                {{/if}} {{if value.tid.is_awesome=="no"}}
                <span class="zan" onclick="getdianzan(this)"><span class="iconfont icon-dianzan zan_icon" style="font-size:0.7rem;"></span>&nbsp;<span class="like like{{value.id}}">{{value.awesome_num+value.virtual_awesome_num}}</span></span>
                {{/if}}
            </div>
        </div>
    </div>
    {{/if}} {{if items[index].top==1}}
    <div class="item" style="margin:0">
        <div class="aui-card-list" style="margin-bottom:0.5rem" articleID="{{value.id}}" onclick="btn_active1(this)">
            <div class="aui-card-list-header aui-card-list-user" style="padding:.3rem .5rem 0.5rem .5rem;">
                <p class="max2line btn_activeId">{{value.title}}</p>
            </div>

            {{if value.news_type == 0}}
            <div class="aui-row aui-row-padded photoList" style="padding:0 .5rem; margin-top:0;">
                {{each items[index].head_img as val ind}}
                <div class="aui-col-xs-4" imgattr="{{val.filepath}}" style="overflow:hidden;text-align:center;" onclick="bigPhoto(this)">
                    <!-- <img data-original="{{val.filepath}}" src="{{val.filepath}}" class="imgList" /> -->
                    <img class="imgList" style="width:100%;height:100%;background-image:url('{{val.original_image}}');background-size:cover" />
                </div>
                {{/each}}
            </div>
            {{/if}} {{if value.news_type == 1}}
            <div class="aui-row aui-row-padded" style="padding: 0 .5rem;">
                <!-- <video src="{{value.video_id.url}}" poster="{{value.head_img[0].filepath}}"></video> -->
                <video src="{{value.video_id.url}}" class="video" poster="9999.jpg" controls x5-video-orientation="landscape" x5-playsinline="" playsinline="" webkit-playsinline="" style='background-image:url("{{value.head_img[0].filepath}}");background-size:100%'>

                </video>
            </div>
            {{/if}}

            <div class="flex-bottom" style="padding:0.2rem .8rem;">
                <div>
                    <span>{{value.read_num + value.virtual_read_num}}</span><span>阅读</span> &nbsp;&nbsp;
                    <span>{{value.create_time}}</span>
                </div>
                <div class="footer_right" articleID="{{value.id}}">
                    <span articleID="{{value.id}}" class="ping btn_activeId" onclick="getcomment(this)"><span articleID="{{value.id}}" class="iconfont icon-pinglunzhuanhuan btn_activeId" style="font-size:0.95rem;"></span>&nbsp;<span class="comment comment{{value.id}}">{{value.comment_num}}</span>                    &nbsp;</span>
                    {{if value.tid.is_awesome=="yes"}}
                    <span class="zan" onclick="getdianzan(this)"><span class="iconfont icon-dianzan zan_icon active" style="font-size:0.7rem;"></span>&nbsp;<span class="like like{{value.id}}">{{value.awesome_num+value.virtual_awesome_num}}</span></span>
                    {{/if}} {{if value.tid.is_awesome=="no"}}
                    <span class="zan" onclick="getdianzan(this)"><span class="iconfont icon-dianzan zan_icon" style="font-size:0.7rem;"></span>&nbsp;<span class="like like{{value.id}}">{{value.awesome_num+value.virtual_awesome_num}}</span></span>
                    {{/if}}
                </div>
            </div>
        </div>
    </div>
    {{/if}} {{/each}}
</script>
<script type="text/javascript">
    apiready = function() {
        var toast = new auiToast({});
        api.setWinAttr({
            bounces: false,
            slidBackEnabled: false,
        });
        // 监听点赞
        api.addEventListener({
            name: "zan_reload"
        }, function(ret, err) {
            var articleID = localStorage.getItem("articleID");
            var val_zan = ret.value.key1;
            boolean = ret.value.key2;
            console.log(boolean);
            if (boolean == "true") {
                $(".like" + articleID).html(val_zan);
                $(".like" + articleID).siblings('.zan_icon').addClass("active")
            };
            if (boolean == "false") {
                $(".like" + articleID).html(val_zan);
                $(".like" + articleID).siblings('.zan_icon').removeClass("active")
            }
        });
        // 监听评论
        api.addEventListener({
            name: "comment_reload"
        }, function(ret, err) {
            var articleID = localStorage.getItem("articleID");
            var val_comment = $(".comment" + articleID).html();
            val_comment++
            $(".comment" + articleID).html(val_comment)
        })
        // 监听搜索
        api.addEventListener({
            name: "search_tosat"
        }, function(ret, err) {
          toast.fail({
              title:"请输入您想搜索的内容!",
              duration:1500
          });
        })
        getbannerList();
        navbarmenu();
        getnewsList(1, '');
        refreshList();
        ios_sh('#codePay'); //ios审核专用
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            return; //禁止去登录页
        });
    }
    var toast = new auiToast({});

    // 轮播图
    function getbannerList() {
        $.ajax({
            type: "get",
            data: {
                type_id: 1
            },
            url: dns + 'banner/read',
            dataType: 'json',
            success: function(res) {
                // console.log(JSON.stringify(res));
                $(".mui-slider-group").empty();
                $(".mui-slider-indicator").empty();
                var length = res.data.length;
                if (length == 1) {
                    $(".mui-slider-group").append('<div class="mui-slider-item" activeId="' + res.data[0].href_url + '"><img class="lunbo-img" src="' + res.data[0].img_id.url + '" /></div>')
                } else {
                    $('.mui-slider-group').append('<div class="mui-slider-item mui-slider-item-duplicate" activeId="' + res.data[length - 1].href_url + '"><img class="lunbo-img" src="' + res.data[length - 1].img_id.url + '" /></div>');
                    $('.mui-slider-indicator').append('<div class="mui-indicator mui-active"></div>');
                    for (var i = 0; i < length; i++) {
                        $('.mui-slider-group').append('<div class="mui-slider-item" activeId="' + res.data[i].href_url + '"><img class="lunbo-img" src="' + res.data[i].img_id.url + '" /></div>');
                    }
                    $('.mui-slider-group').append('<div class="mui-slider-item mui-slider-item-duplicate" activeId="' + res.data[0].href_url + '"><img class="lunbo-img" src="' + res.data[0].img_id.url + '" /></div>');
                    for (var i = 0; i < length - 1; i++) {
                        $('.mui-slider-indicator').append('<div class="mui-indicator"></div>');
                    }
                };
                var slider = mui('.mui-slider');
                slider.slider({
                    interval: 5000 //自动轮播周期，若为0则不自动播放，默认为0；
                });
                // 点击图片跳转对应详情
                $(".mui-slider-item").each(function() {
                    $(this).click(function() {
                        var activeId = $(this).attr("activeId"); //自定义属性的值
                        var index = activeId.indexOf("="); //索引
                        var type = activeId.substr(0, index); //类型
                        var id = activeId.substr(index + 1); //id
                        if (type == "news") {
                            localStorage.setItem("articleID", id);
                            // 跳转到其它页面暂停当前页面的视频
                            getvideo()
                            api.openWin({
                                name: 'article',
                                url: './frame0/article.html',
                                allowEdit: true,
                                pageParam: {}, //页面代参数
                                rect: {
                                    x: 0,
                                    y: 0,
                                    w: api.winWidth,
                                    h: api.winHeight
                                }
                            });
                        };
                        if (type == "booking") {
                            localStorage.setItem("articleID", id);
                            // 跳转到其它页面暂停当前页面的视频
                            getvideo()
                            api.openWin({
                                name: 'frame1-details',
                                url: './frame1/frame1_details.html',
                                allowEdit: true,
                                pageParam: {}, //页面代参数
                                rect: {
                                    x: 0,
                                    y: 0,
                                    w: api.winWidth,
                                    h: api.winHeight
                                }
                            });
                        };

                    })
                })
            }
        })
    }
    //导航分类
    function navbarmenu() {
        $.ajax({
            type: 'get',
            url: dns + 'newscate/read',
            success: function(res) {
                //console.log(JSON.stringify(res));
                var idList = [];
                var itemList = [];
                var data = res.data;
                for (var i = 0; i < data.length; i++) {
                    idList.push(data[i].id)
                };
                // 获取items数组
                for (var i = 0; i < data.length; i++) {
                    itemList.push(data[i].title)
                };
                itemList.unshift("全部");
                var html = template("tabList", {
                    "items": itemList
                });
                document.getElementById("tabBox").innerHTML = html;
                $("#tabBox").find(".tab_item").eq(0).addClass("active");
                $(".tab_item").each(function() {
                    $(this).click(function() {
                        $("#down").css("display", "none")
                        var index = $(this).index()
                        $(this).siblings(".tab_item").removeClass("active");
                        $(this).addClass("active");
                        if (index == 0) {
                            getnewsList(1, '');
                        };
                        // 当点击其他按钮时
                        if (index != 0) {
                            id = idList[index - 1]
                            getnewsList(1, id);
                        }
                    })
                })
            }
        })
    };
    // 新闻列表
    function getnewsList(page, type) {
        var token = localStorage.getItem("token");
        $.ajax({
            url: dns + 'news/read',
            data: {
                page: page,
                limit: 20,
                type: type
            },
            type: "get",
            dataType: 'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success: function(res) {
                // console.log(JSON.stringify(res));
                var html = template("newsAll", {
                    "items": res.data
                });
                document.getElementById("newsListAll").innerHTML = html;
                // 适配video宽高
                var width = $("video").width();
                var height = width/16*9;
                $("video").height(height)
                // 切换底部tab时暂停视频
                api.addEventListener({
                        name: "video_index"
                    }, function(ret, err) {
                        getvideo()
                    })
                    // 监听页面到达最底部时上拉加载
                var page = 1;
                api.addEventListener({
                    name: 'scrolltobottom',
                    extra: {
                        threshold: 0 //设置距离底部多少距离时触发，默认值为0，数字类型
                    }
                }, function(ret, err) {
                    page++;
                    var token = localStorage.getItem("token");
                    $.ajax({
                        url: dns + 'news/read',
                        data: {
                            page: page,
                            limit: 20,
                            type: type
                        },
                        type: "get",
                        dataType: 'json',
                        beforeSend: function(request) {
                            request.setRequestHeader("token",token);
                        },
                        success: function(res) {
                            // console.log(JSON.stringify(res));
                            if (res.count == 0) {
                                $("#down").css("display","block");
                                return false;
                            }
                            var html = template("newsAll", {
                                "items": res.data
                            });
                            // 适配video宽高
                            var width = $("video").width();
                            var height = width/16*9;
                            $("video").height(height)
                            // console.log(JSON.stringify(html));
                            $("#newsListAll").append(html);

                            // 切换底部tab时暂停视频
                            api.addEventListener({
                                name: "video_index"
                            }, function(ret, err) {
                                getvideo()
                            })
                        },
                        error: function(err){
                            console.log(JSON.parse(err.responseText).msg);
                        }
                    })
                });

            },
            error: function(err) {
                console.log(JSON.parse(err.responseText).msg);
            }
        })
    }
    // 跳转文化旅游页面
    function btn_travel() {
        // 跳转到其它页面暂停当前页面的视频
        getvideo()
        api.openWin({
            name: 'travel',
            url: './frame0/travel.html',
            allowEdit: true,
            pageParam: {}, //页面代参数
            rect: {
                x: 0,
                y: 25,
                w: api.winWidth,
                h: api.winHeight
            }
        });
    }
    // 跳转美食
    function btn_cate() {
        // 跳转到其它页面暂停当前页面的视频
        getvideo()
        api.openWin({
            name: 'cate',
            url: './frame0/cate.html',
            allowEdit: true,
            pageParam: {

            }, //页面代参数
            rect: {
                x: 0,
                y: 25,
                w: api.winWidth,
                h: api.winHeight
            },
            allowEdit: true

        });
    }
    // 跳转卡包
    function btn_giftBag() {
      // 获取此时的毫秒数
      var newTime = new Date();
      var getnewTime = newTime.getTime();
      // 获取登陆时的毫秒数
      var getloginTime = localStorage.getItem("getloginTime");
      var Time = getnewTime-getloginTime;
      var token = localStorage.getItem("token");
      var cacheTime = localStorage.getItem("cacheTime");
      if(Time>cacheTime||!token){
        api.confirm({
            title: "当前游客状态",
            msg: "需要前往登录页面,是否继续?",
            buttons: ["是", "否"]
        }, function(ret, err) {
          if(ret.buttonIndex == 1){
            toast.loading({
                    title:"跳转中",
                    duration:2000
                },function(ret){
                    setTimeout(function(){
                        toast.hide();
                    }, 3000)
                });
            setTimeout(function () {
              api.openWin({
                  name: 'login',
                  url: './system/login.html',
                  allowEdit: true,
                  pageParam: {}, //页面代参数
                  rect: {
                      x: 0,
                      y: 0,
                      w: api.winWidth,
                      h: api.winHeight
                  }
              });
            },1000)
          }
        });
        return false;
      }
        // 跳转到其它页面暂停当前页面的视频
        getvideo()
        api.openWin({
            name: 'gift-bag',
            url: './frame0/gift-bag-lingqu.html',
            allowEdit: true,
            pageParam: {}, //页面代参数
            rect: {
                x: 0,
                y: 25,
                w: api.winWidth,
                h: api.winHeight
            }
        });
    }
    // 跳转推广
    function btn_generalize() {
        // 跳转到其它页面暂停当前页面的视频
        getvideo()
        api.openWin({
            name: 'generalize',
            url: './frame4/hezuo/index.html',
            allowEdit: true,
            pageParam: {}, //页面代参数
            rect: {
                x: 0,
                y: 0,
                w: api.winWidth,
                h: api.winHeight
            }
        });
    }
    // 跳转文章详情
    function btn_active1(e) {
        var articleID = $(e).attr("articleID");
        localStorage.setItem("articleID", articleID);
        // 跳转到其它页面暂停当前页面的视频
        getvideo()
        api.openWin({
            name: 'article',
            url: './frame0/article.html',
            allowEdit: true,
            pageParam: {}, //页面代参数
            rect: {
                x: 0,
                y: 0,
                w: api.winWidth,
                h: api.winHeight
            }
        });
    }
    // 扫码支付
    function codePay(perm) {
        if (!confirmPer(perm)) {
          toast.fail({
              title:"您当前没有权限!",
              duration:2000
          });
            return;
        }

        if (perm == 'camera') { //相机权限
            var FNScanner = api.require('FNScanner');
            FNScanner.open({
                autorotation: true
            }, function(ret, err) {
                if (ret) {

                  console.log(JSON.stringify(ret));
                    if (ret.eventType == 'success') { //跳到支付页面
                        $.ajax({
                            url: dns + 'pay/offline',
                            type: 'GET',
                            data: {
                                'mid':  ret.content
                            },
                            beforeSend: function(request) {
                                request.setRequestHeader("token", localStorage.getItem('token'));
                            },
                            success: function(res) {
                              console.log(JSON.stringify(res));
                              if(res.data.merchant.id){
                                api.openWin({
                                    name: 'pay',
                                    url: './pay/index.html',
                                    allowEdit: true,
                                    pageParam: {
                                        'mid': ret.content
                                    }, //页面代参数
                                    rect: {
                                        x: 0,
                                        y: 0,
                                        w: api.winWidth,
                                        h: api.winHeight
                                    }
                                });
                                getvideo();
                                // 跳转到其它页面暂停当前页面的视频
                              }else{
                                toast.fail({
                                    title:"请扫描正确的商家码!",
                                    duration:3000
                                });
                                  return;
                              }
                            },
                            error:function (err) {
                              toast.fail({
                                  title:JSON.parse(err.responseText).msg,
                                  duration:3000
                              });
                                return;

                            }
                          });
                    }else{
                    setTimeout(function () {
                      toast.fail({
                          title:"请扫描正确的商家码!",
                          duration:3000
                      });
                        return;
                    },2000)
                    }
                } else {
                    //失败回调


                }
            });
        }
    }
    // 点赞，取消点赞
    function getdianzan(e) {
        //如果提供了事件对象，则这是一个非IE浏览器
        if ( e && e.stopPropagation ){
            //因此它支持W3C的stopPropagation()方法
          e.stopPropagation();
        }
        else {
            //否则，我们需要使用IE的方式来取消事件冒泡
            window.event.cancelBubble = true;
        }
        // 获取此时的毫秒数
        var newTime = new Date();
        var getnewTime = newTime.getTime();
        // 获取登陆时的毫秒数
        var getloginTime = localStorage.getItem("getloginTime");
        var Time = getnewTime-getloginTime;
        var token = localStorage.getItem("token");
        var cacheTime = localStorage.getItem("cacheTime");
        if(Time>cacheTime||!token){
          api.confirm({
              title: "当前游客状态",
              msg: "需要前往登录页面,是否继续?",
              buttons: ["是", "否"]
          }, function(ret, err) {
            if(ret.buttonIndex == 1){
              toast.loading({
                      title:"跳转中",
                      duration:2000
                  },function(ret){
                      setTimeout(function(){
                          toast.hide();
                      }, 3000)
                  });
              setTimeout(function () {
                api.openWin({
                    name: 'login',
                    url: './system/login.html',
                    allowEdit: true,
                    pageParam: {}, //页面代参数
                    rect: {
                        x: 0,
                        y: 0,
                        w: api.winWidth,
                        h: api.winHeight
                    }
                });
              },1000)
            }
          });
          return false;
        }
        var articleID = $(e).parent().attr("articleID");
        var val = $(e).find(".like").text();
        $.ajax({
            type: "post",
            data: {
                type: 1,
                article: articleID
            },
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            url: dns + "like/okorno",
            success: function(res){
                if (res.msg == "成功点赞") {
                    $(e).find(".zan_icon").addClass("active");
                    val++;
                    $(e).find(".like").text(val);
                    toast.custom({
                      title:"成功点赞!",
                      html:'<i class="aui-iconfont aui-icon-laud"></i>',
                      duration:1500
                    });
                };
                if (res.msg == "取消点赞") {
                    $(e).find(".zan_icon").removeClass("active");
                    val--;
                    $(e).find(".like").text(val);
                }
            }
        });
    }
    // 评论
    function getcomment(e) {
        //如果提供了事件对象，则这是一个非IE浏览器
        if ( e && e.stopPropagation ){
            //因此它支持W3C的stopPropagation()方法
          e.stopPropagation();
        }
        else {
            //否则，我们需要使用IE的方式来取消事件冒泡
            window.event.cancelBubble = true;
        }
        var articleID = $(e).parent().attr("articleID");
        localStorage.setItem("articleID", articleID);
        // 跳转到其它页面暂停当前页面的视频
        getvideo()
        api.openWin({
            name: 'article',
            url: './frame0/article.html',
            allowEdit: true,
            pageParam: {}, //页面代参数
            rect: {
                x: 0,
                y: 0,
                w: api.winWidth,
                h: api.winHeight
            }
        });
    }
    // // 更多活动图
    $(".more").click(function(e) {
        e.stopPropagation()
            // 跳转到其它页面暂停当前页面的视频
        getvideo()
        api.openWin({
            name: 'banner',
            url: './frame0/banner.html',
            pageParam: {}, //页面代参数
            rect: {
                x: 0,
                y: 0,
                w: api.winWidth,
                h: api.winHeight
            }
        });
    })
    //该方法用来下拉刷新
    function refreshList() {
        api.setCustomRefreshHeaderInfo({
            bgColor: '#eee',
            images: [
                'widget://image/xiaolong/1.png',
                'widget://image/xiaolong/2.png',
                'widget://image/xiaolong/3.png',
                'widget://image/xiaolong/4.png',
                'widget://image/xiaolong/5.png',
            ],
            tips: {
                pull: '下拉刷新' + '\n',
                threshold: '松开立即刷新' + '\n',
                load: '正在刷新' + '\n'
            }
        }, function() {
            setTimeout(function() {
                api.refreshHeaderLoadDone();
                window.location.reload();
            }, 1000);
        });
    }
    // 图片放大
    function bigPhoto(e) {
        //如果提供了事件对象，则这是一个非IE浏览器
        if ( e && e.stopPropagation ){
            //因此它支持W3C的stopPropagation()方法
          e.stopPropagation();
        }
        else {
            //否则，我们需要使用IE的方式来取消事件冒泡
            window.event.cancelBubble = true;
        }
        var ind = $(e).index();
        var imgList = [];
        $(e).parent().find(".aui-col-xs-4").each(function() {
                imgList.push($(this).attr("imgattr"))
            })
            //console.log(imgList);
        var photoBrowser = api.require('photoBrowser');
        photoBrowser.open({
            images: imgList,
            placeholderImg: 'widget://res/img/apicloud.png',
            bgColor: '#000',
            activeIndex: ind
        }, function(ret, err) {
            if (ret.eventType == 'click') {
                photoBrowser.close()
            }
            if (ret.eventType == 'longPress') {
                var a = Math.floor(Math.random() * 1000);
                //  console.log(imgList[ret.index]);
                var retIndex = ret.index;
                api.confirm({
                    title: "温馨提示",
                    msg: "是否保存图片?",
                    buttons: ["是", "否"]
                }, function(ret, err) {
                    if (ret.buttonIndex == 1) { //确认退出
                        api.download({
                            url: imgList[retIndex],
                            savePath: 'fs://' + a + '.jpg',
                            report: true,
                            cache: false,
                        }, function(ret, err) {
                            if (ret.state == 1) {
                                //  console.log(JSON.stringify(ret));
                                //下载成功
                                // console.log("下载成功");
                                // 保存图片
                                api.saveMediaToAlbum({
                                    path: ret.savePath
                                }, function(ret, err) {
                                    if (ret.status == true) {
                                        alert("保存成功!")
                                    } else {}
                                });
                            } else {

                            }
                        });
                    } else {
                        return;
                    }
                });
            } else {
                // alert(JSON.stringify(err));
            }
        });
    }

    function getvideo() {
        // 跳转到其它页面暂停当前页面的视频
        var videoList = document.getElementsByTagName("video");
        for (var i = 0; i < videoList.length; i++) {
            if (!videoList[i].paused) {
                videoList[i].pause(); //暂停控制
            }
        }
    }
</script>
<script>
	var id_shadowBox = document.getElementById("id_shadowBox");
	var id_box = document.getElementById("id_box");
	var id_box2 = document.getElementById("id_box2");
    // localStorage.setItem("ifHint2",'');
	if(!localStorage.getItem("ifHint2")){//判断是否是第一次进入app
		id_shadowBox.style.display = "flex";
        $("body,html").css({"overflow":"hidden"});
	}
	function btnLeft(){//点击暂不使用時
		id_box.style.display = "none";
		id_box2.style.display = "block";
	}
	function btnRight(){//点击授权时
		id_shadowBox.style.display = "none";
		localStorage.setItem("ifHint2","true");
        $("body,html").css({"overflow":"visible"})
	}
	function btnYes(){//点击确定時
		id_box2.style.display = "none";
		id_box.style.display = "block";
	}
    function btn_win() {//跳转协议
        api.openWin({
            name: 'aboutus',
            url: './frame4/aboutus/index.html',
            allowEdit:true,
            pageParam: {} //页面代参数
        });
    }
</script>
</html>
